<template>
	<view>
		<view class="box">
			<view>申请</view>
			<view class="box_word" >
			<input placeholder="输入后查找" type="text" @blur="getDaili" v-model="form.realName" />
			</view>
		</view>
		<view class="box">
			<view>名称</view>
			<view class="box_word" >
				<input placeholder="请输入" type="text" v-model="form.name" />
			</view>
		</view>
		<view class="box">
			<view>地址</view>
			<view class="box_word" >
				<input placeholder="请输入" type="text" v-model="form.address" />
			</view>
		</view>
		<view class="box">
			<view>电话</view>
			<view class="box_word" >
				<input placeholder="请输入" type="text" v-model="form.phone" />
			</view>
		</view>

		<view class="btnd" @click="sqbtn">
			修改
		</view>
		<view class="btnx" @click="goback">
			返回
		</view>
	<uni-popup ref="popup" type="bottom">
		<view class="tc_box">
			<view class="tc_content" v-for="(v,i) in list" @click="getrealName(v)">
				<view>
				{{v.nickname}}
				</view>
				<view>
				{{v.phone==null?'':v.phone}}
				</view>
			</view>

<!-- 			<view class="bottompage">
				<view class="bottompage_1" >
					下一页
				</view>
				<view class="bottompage_2" >
					上一页
				</view>
			</view> -->

		</view>
	</uni-popup>
	
	</view>
</template>

<script>
	import {jxsInfouserList,jxsInfogetInfo,jxsInfosetUser} from "../../../api/order.js"
	export default {
		data() {
			return {
				form:{
					pid:"",
					name:"",
					address:"",
					phone:"",
					Ischoose:false
				},
				realName:"",
				list:[],
			}
		},
		onLoad(e) {
			console.log("eeee");
			console.log(e);
			// this.form.pid=e.id
			this.id=e.id
			// this.realName=e.realName
		},
		onShow() {
			this.getData()
		},
		methods: {
			getrealName(v){
				this.form.nickname=v.nickname
				this.form.uid=v.uid
				this.Ischoose=true
				this.$forceUpdate()
				this.close()
			},
			
			getDaili(){
				jxsInfouserList({realName:this.form.realName}).then(res=>{
					if(res.status!=200){
						uni.showToast({
							title:res.msg,
							icon:"none", 
							duration:2000
						})
						return
					}
					this.list=res.data.records
					if(this.list.length==0){
						uni.showToast({
							title:"没有查找到改用户",
							icon:"none",
							duration:2000
						})
						return
					}
					this.open()
				})
			},
		getData(){
			jxsInfogetInfo({id:this.id}).then(res=>{
				if(res.status!=200){
					uni.showToast({
						title:res.msg,
						icon:"none",
						duration:2000
					})
					return
				}
				this.form=res.data
				console.log("详情");
				console.log(res);
				
			})
		},
		
			open() {
				this.Ischoose=false
				// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ，type 属性将失效 ，仅支持 ['top','left','bottom','right','center']
				this.$refs.popup.open('top')
			},
			close() {
				this.$refs.popup.close()
			},
			
			showModel(){
				this.open()
			},
			
			
		
			sqbtn(){
				if(!this.Ischoose){
					uni.showToast({
						title:"请选择搜索的内容",
						icon:"none",
						duration:2000
					})
					return
				}
				if(this.form.name==''){
					uni.showToast({
						title:"名称必填",
						icon:"none",
						duration:2000
					})
					return
				}

				if(!(/^[1]([3-9])[0-9]{9}$/.test(this.form.phone))){
					uni.showToast({
						title:"电话不正确",
						icon:"none",
						duration:2000
					})
					return 
				}
				jxsInfosetUser(this.form).then(res=>{
					if(res.status!=200){
					uni.showToast({
						title: res.msg,
						icon: 'none',
						duration: 2000
					})} else{
						uni.showToast({
							title: "申请成功",
							icon: 'none',
							duration: 2000
						})
						this.goback()
						
					}
			})
			},
			goback(){
			uni.navigateBack({
				
			})
			}, 
		}
	}
</script>

<style scoped lang="less">

	.tc_box {
		// height: 100vh;
		// overflow: scroll;
		background: white;
	}
	.tc_content {
		padding: 40upx;
		display: flex;
		justify-content: space-between;
		border-bottom: 1px solid #aaaaaa;
	}
	.bottompage{
		text-align: center;
		view{
			padding: 40upx;
			border-bottom: 1px solid #aaaaaa;
		}
	}
	.box{
		
		width: 690upx;
		height: 70upx;
		margin: 0 auto;
		display: flex;
		justify-content: space-between;
		text-align: center;
		border-bottom: 1px solid rgba(0, 0, 0, 0.1);
		margin-top: 30upx;
	}
	.box_word{
		font-size: 17 upx;
		input{
			width: 100%;
			text-align: right;
		}
		// color: #0000004D;
		

	}
	.bzitem{
		width: 690upx;
		height: 270upx;
		margin: 0 auto;
		background-color: #EFEFF4;
		color: #282828;
		padding: 20upx;
	}
	.btnd{
		width: 300upx;
		height: 70upx;
		margin: 20upx auto;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #07c160;
		border-radius: 20upx; 
		color: #FFFFFF;
	}
	.btnx{
		
		width: 300upx;
		height: 70upx;
		margin: 10upx auto;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #ff0000;
		border-radius: 20upx; 
		color: #FFFFFF;
	}
</style>
